import re
from common.response import JsonResponse
from common.constant import CODE_PARAMETER_ERROR, MSG_PARAMETER_ERROR, CODE_BUSSINESS_ERROR
from rest_framework.decorators import api_view
from .utils import save_file, send_file
import os


@api_view(['POST'])
def upload_install_file(request):
    file = request.FILES['file']
    save_file(file, 'static'+os.sep+'install.apk')
    return JsonResponse(data=None)


@api_view(['GET'])
def get_install_apk(request):
    return send_file('static'+os.sep+'install.apk', 'install.apk')


@api_view(['GET'])
def get_tools_apk(request):
    return send_file('static'+os.sep+'tools.apk', 'tools.apk')
